home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Resources / Developers / XAMPP 1.5.4 / Windows installer / xampp-win32-1.5.4-installer.exe / xampp / xampp-portcheck.exe / checkports.vbs next >
Encoding:
Text File  |  2005-07-22  |  6.3 KB  |  169 lines

  1. Option Explicit
  2. '***************************************************************
  3. '*                  XAMPP PortCheck v1.2                       *
  4. '*                                                             *
  5. '*     (c) 2005 Carsten Wiedmann <info@wiedmann-online.de>     *
  6. '***************************************************************
  7. '**Start Encode**
  8. Dim WshShell, WshSysEnv, objExec
  9. Dim strOpenPorts, strListenPorts, strAusgabe, strOS, strTemp
  10. Dim arrOpenPorts, arrListenPorts(), arrSplitListenPorts(), arrXAMPPPorts(), arrTempA, arrTempB()
  11. Dim intZaehlerA, intZaehlerB, intPort
  12.  
  13. Set WshShell = CreateObject("WScript.Shell")
  14.  
  15. If 0 = Instr(LCase(WScript.FullName), "cscript.exe") Then
  16.     WshShell.Run "CScript.exe //Nologo " & WScript.ScriptName
  17.     Set WshShell = Nothing
  18.     WScript.Quit()
  19. End If
  20.  
  21. Set WshSysEnv = WshShell.Environment("Process")
  22. strOS = WshSysEnv("OS")
  23. Set WshSysEnv = Nothing
  24.  
  25. WshShell.AppActivate "cscript.exe"
  26. strAusgabe = vbNewLine & "***************************************************************" & vbNewLine
  27. strAusgabe = strAusgabe & "*                  XAMPP PortCheck v1.2                       *" & vbNewLine
  28. strAusgabe = strAusgabe & "*                                                             *" & vbNewLine
  29. strAusgabe = strAusgabe & "*     (c) 2005 Carsten Wiedmann <info@wiedmann-online.de>     *" & vbNewLine
  30. strAusgabe = strAusgabe & "*                                                             *" & vbNewLine
  31. strAusgabe = strAusgabe & "* This script uses openport.exe:                              *" & vbNewLine
  32. strAusgabe = strAusgabe & "* (c) 2003 DiamondCS <http://www.diamondcs.com.au/openports/> *" & vbNewLine
  33. strAusgabe = strAusgabe & "***************************************************************" & vbNewLine & vbNewLine
  34. strAusgabe = strAusgabe & "Please wait a moment..."
  35. Wscript.Echo strAusgabe
  36.  
  37. If LCase(strOS) = "windows_nt" Then
  38.     strOpenPorts = ""
  39.     Set objExec = WshShell.Exec("openports.exe -csv -path")
  40.     If Not objExec.StdOut.AtEndOfStream Then
  41.         strOpenPorts = objExec.StdOut.ReadAll
  42.     End If
  43.     arrOpenPorts = Split(strOpenPorts, vbNewLine)
  44.  
  45.     Set objExec = Nothing
  46.     Set WshShell = Nothing
  47.  
  48.     intZaehlerA = 0
  49.     ReDim arrListenPorts(intZaehlerA)
  50.     For Each strListenPorts In arrOpenPorts
  51.         If 0 < Instr(strListenPorts, "LISTENING") Then
  52.             ReDim Preserve arrListenPorts(intZaehlerA)
  53.             arrListenPorts(intZaehlerA) = strListenPorts
  54.             intZaehlerA = intZaehlerA + 1
  55.         End If
  56.     Next
  57.     Erase arrOpenPorts
  58.  
  59.     intZaehlerA = 0
  60.     ReDim arrSplitListenPorts(7, intZaehlerA)
  61.     For Each strListenPorts In arrListenPorts
  62.         ReDim Preserve arrSplitListenPorts(7, intZaehlerA)
  63.         arrTempA = Split(strListenPorts, ",")
  64.  
  65.         For intZaehlerB = 0 To 7
  66.             arrSplitListenPorts(intZaehlerB, intZaehlerA) = arrTempA(intZaehlerB)
  67.         Next
  68.  
  69.         intZaehlerA = intZaehlerA + 1
  70.     Next
  71.     Erase arrTempA
  72.     Erase arrListenPorts
  73. Else
  74.     strOpenPorts = ""
  75.     Set objExec = WshShell.Exec("netstat -a -n")
  76.     If Not objExec.StdOut.AtEndOfStream Then
  77.         strOpenPorts = objExec.StdOut.ReadAll
  78.     End If
  79.     arrOpenPorts = Split(strOpenPorts, vbNewLine)
  80.  
  81.     Set objExec = Nothing
  82.     Set WshShell = Nothing
  83.  
  84.     intZaehlerA = 0
  85.     ReDim arrListenPorts(intZaehlerA)
  86.     For Each strListenPorts In arrOpenPorts
  87.         If 0 < Instr(strListenPorts, " TCP ") Or 0 < Instr(strListenPorts, " UDP ") Then
  88.             ReDim Preserve arrListenPorts(intZaehlerA)
  89.             arrListenPorts(intZaehlerA) = strListenPorts
  90.             intZaehlerA = intZaehlerA + 1
  91.         End If
  92.     Next
  93.     Erase arrOpenPorts
  94.  
  95.     intZaehlerA = 0
  96.     ReDim arrSplitListenPorts(7, intZaehlerA)
  97.     For Each strListenPorts In arrListenPorts
  98.         ReDim Preserve arrSplitListenPorts(7, intZaehlerA)
  99.         arrTempA = Split(strListenPorts, " ")
  100.  
  101.         intZaehlerB = 0
  102.         ReDim arrTempB(intZaehlerB)
  103.         For Each strTemp In arrTempA
  104.             If 0 <> Len(strTemp) Then
  105.                 ReDim Preserve arrTempB(intZaehlerB)
  106.                 arrTempB(intZaehlerB) = strTemp
  107.                 intZaehlerB = intZaehlerB + 1
  108.             End If
  109.         Next
  110.         arrSplitListenPorts(2, intZaehlerA) = "in use (endpoint is not available with this OS)"
  111.         arrSplitListenPorts(4, intZaehlerA) = Right(arrTempB(1), Len(arrTempB(1)) -  InstrRev(arrTempB(1), ":"))
  112.  
  113.         intZaehlerA = intZaehlerA + 1
  114.     Next
  115.     Erase arrTempA
  116.     Erase arrTempB
  117.     Erase arrListenPorts
  118. End If
  119.  
  120. ReDim arrXAMPPPorts(8)
  121. For intZaehlerA = 0 to 8
  122.     arrXAMPPPorts(intZaehlerA) = "free"
  123. Next
  124. For intZaehlerA = 0 To UBound(arrSplitListenPorts, 2)
  125.     intPort = arrSplitListenPorts(4, intZaehlerA)
  126.     Select Case intPort
  127.         Case 80
  128.             arrXAMPPPorts(0)    = arrSplitListenPorts(2, intZaehlerA)
  129.         Case 81
  130.             arrXAMPPPorts(1)    = arrSplitListenPorts(2, intZaehlerA)
  131.         Case 443
  132.             arrXAMPPPorts(2)    = arrSplitListenPorts(2, intZaehlerA)
  133.         Case 3306
  134.             arrXAMPPPorts(3)    = arrSplitListenPorts(2, intZaehlerA)
  135.         Case 21
  136.             arrXAMPPPorts(4)    = arrSplitListenPorts(2, intZaehlerA)
  137.         Case 14147
  138.             arrXAMPPPorts(5)    = arrSplitListenPorts(2, intZaehlerA)
  139.         Case 25
  140.             arrXAMPPPorts(6)    = arrSplitListenPorts(2, intZaehlerA)
  141.         Case 110
  142.             arrXAMPPPorts(7)    = arrSplitListenPorts(2, intZaehlerA)
  143.         Case 143
  144.             arrXAMPPPorts(8)    = arrSplitListenPorts(2, intZaehlerA)
  145.     End Select
  146. Next
  147. Erase arrSplitListenPorts
  148.  
  149. strAusgabe = vbNewLine & vbNewLine & "RESULT" & vbNewLine
  150. strAusgabe = strAusgabe & "------" & vbNewLine & vbNewLine
  151. strAusgabe = strAusgabe & "Service              Port   Status" & vbNewLine
  152. strAusgabe = strAusgabe & "==============================================================================" & vbNewLine
  153. strAusgabe = strAusgabe & "Apache (HTTP)          80   " & arrXAMPPPorts(0) & vbNewLine
  154. strAusgabe = strAusgabe & "Apache (WebDAV)        81   " & arrXAMPPPorts(1) & vbNewLine
  155. strAusgabe = strAusgabe & "Apache (HTTPS)        443   " & arrXAMPPPorts(2) & vbNewLine & vbNewLine
  156. strAusgabe = strAusgabe & "MySQL                3306   " & arrXAMPPPorts(3) & vbNewLine & vbNewLine
  157. strAusgabe = strAusgabe & "FileZilla (FTP)        21   " & arrXAMPPPorts(4) & vbNewLine
  158. strAusgabe = strAusgabe & "FileZilla (Admin)   14147   " & arrXAMPPPorts(5) & vbNewLine & vbNewLine
  159. strAusgabe = strAusgabe & "Mercury (SMTP)         25   " & arrXAMPPPorts(6) & vbNewLine
  160. strAusgabe = strAusgabe & "Mercury (POP3)        110   " & arrXAMPPPorts(7) & vbNewLine
  161. strAusgabe = strAusgabe & "Mercury (IMAP)        143   " & arrXAMPPPorts(8)
  162. Wscript.Echo strAusgabe
  163. Erase arrXAMPPPorts
  164.  
  165. WScript.Echo vbNewLine & "Press <Return> to continue."
  166. WScript.StdIn.ReadLine
  167.  
  168. WScript.Quit()
  169.